import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'dart:async';
import 'package:hairen_app/pages/tabView/my_page_view.dart';
import 'package:hairen_app/pages/plug/drawer.dart';
import 'package:hairen_app/pages/user/login.dart';
import 'package:hairen_app/server/saveInfo.dart';
import 'dart:convert';
import 'package:scoped_model/scoped_model.dart';
import 'package:hairen_app/server/state/UserInfoModel.dart';

class PublishPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new PublishPageState();
}

class PublishPageState extends State<PublishPage> {
  Map userInfo = {};
  String token = "";

  final TextEditingController _Text = new TextEditingController();

  getInfo() {
    SaveInfo.getUserToken().then((Map ret) {
      setState(() {
        userInfo = ret['userInfo'];
        token = ret['token'];
        if (token != "") {
          UserInfoModel.isLogin = true;
        } else {
          UserInfoModel.isLogin = false;
        }
      });
    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getInfo();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Color.fromRGBO(234, 234, 234, 1.0),
      appBar: new AppBar(
        backgroundColor: Color.fromRGBO(251, 114, 153, 1.0),
        leading: new IconButton(icon: new Icon(Icons.arrow_back), onPressed: (){
          Navigator.of(context).pop();
        }),
        title: new Align(
          child: new Text(
            '动态',
            style: new TextStyle(
              color: Colors.white,
            ),
          ),
        ),
        actions: [
          new IconButton(
              icon: new Icon(
                Icons.edit,
                color: Colors.white,
              ),
              onPressed: null)
        ],
      ),
      drawer: new DrawerPage(),
      body: new Container(
        margin: EdgeInsets.all(15.0),
        child:   new Container(
          child: new Column(
            children: <Widget>[
              new Container(
                color: Colors.white,
                padding: EdgeInsets.only(
                  left: 10.0,
                  right: 10.0,
                ),
                child: new TextField(
                  decoration: new InputDecoration(
                      hintText: "发布",
                      border: InputBorder.none,
                      fillColor: Colors.white),
                  maxLines: 4,
                  controller: _Text,
                ),
              ),
              new SizedBox(
                height: 10.0,
              ),
              new Row(
                children: <Widget>[
                  new Expanded(
                      flex: 1,
                      child: new Container(
                        alignment: Alignment.centerLeft,
                        child: new InkWell(
                          child: new Icon(
                            Icons.insert_emoticon,
                            size: 30.0,
                          ),
                          onTap: () {
                            _Text.addListener((){

                            });
                            print(2121);
                          },
                        ),
                      )),
                  new Expanded(
                    flex: 2,
                    child: new Text(''),
                  ),
                  new Expanded(
                    flex: 1,
                    child: FlatButton(
                        padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
                        color: Theme.of(context).backgroundColor,
                        onPressed: () {},
                        child: new Text(
                          '发布',
                          style: new TextStyle(color: Colors.white),
                        )),
                  )
                ],
              ),
            ],
          ),
        ),
      )
    );
  }
}
